Repository navigation
Reimplement 18 TribesState functions at 100% from #279, plus 5 with register allocation differences - #555
Reimplement 18 TribesState functions at 100% from #279, plus 5 with register allocation differences#555gynt wants to merge 40 commits into
Conversation
The function returns nothing: the value left in EAX is the quotient of the idiv on the early exit, the y coordinate or the path test's 0 at the end of the search, and its only caller (updateTribeCombatStanceBehavior, 0x52AC9A) ignores it. The reimplementation in the next commits is `void`, and with main's `int` declaration it does not compile (C2440 in the resolver), so the declaration and the resolver type in TribesState.func.hpp change with it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::addUnitToTribe from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::createTribe from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::createTribeForPlayer from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::getAvailableTribeID from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::getUnitIDForIndexInTribe from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::moveUnitToBehaviorTarget from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::processDeerMoving from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::removeUnitFromThisTribeIfInTribe from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::removeUnitFromTribe from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::snapshotSelectionTribeAndComputeStance from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::spawnDeerLionOrRabbit from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::trimTribeToSize from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::updateCamelTribeBehavior from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::updateLionWolfTribeBehavior from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::updateRabbitTribeBehavior from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::upgradeTribeArrayLayoutForMapVersion from sourcehold#279. Measured at 100.0 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::playUnitMoveSpeech from sourcehold#279. Measured at 99.4 / normalized 100.0 on origin/main f28b77b (full build, both resolver sets on, reccmp). The only difference is the target of the two tail jumps to SFXState::playSpeechSFX (0x0044A3A0), which in ours go through main's trampoline; counted as 100% by main's convention. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::moveTribeToIndexedNearbyTile from sourcehold#279. Measured at 98.6 / normalized 95.2 on origin/main f28b77b (full build, both resolver sets on, reccmp). The one differing line is the loop-end compare: both binaries compare against 0xb4df44 (&field_0xcc4[40].y, 4 bytes past UnitSelectionDefinedData), which reccmp names after the next global in ours and leaves unnamed in the original. Counted as 100% by main's convention (as 0x004DA200, 0x004DA300, 0x004DAE00). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
sourcehold#554 carries TribesState::addUnitToTribe too, written `size++` where this branch had `++size`. Taking its exact text makes the two PRs add an identical file, so whichever merges second has no conflict on it. Still 100.0 / normalized 100.0 (full build and reccmp on f28b77b). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
|
Style guide reading (advisory, posted once) 15 possible deviation(s) from REIMPLEMENTATION_STYLE_GUIDE.md across 4 of the 18 reimplemented The match comes first. Where the ugly form is what matched, it stays -- that is the guide's own overriding rule, and rule 21 asks for a one-line comment saying what was measured so the next reader does not retry it. This report is posted once, when the PR opens, and is not repeated on later pushes.
WhereRule 18 — Use the name, not the number
Rule 23 — Prefer if-else over ternary
Rule 24 — Declare variables upon first use
|
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::createAnimal from sourcehold#279, with the style pass. Measured at 96.1 / normalized 77.6 on origin/main 592a17d (full build, both resolver sets on, reccmp). Remaining: the reloads of x and y from their parameter slots for the three spawn-point calls, and their pushes, use other registers and are ordered around the store to herdMaxSize; the same values are pushed in the same order. No functional difference. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::playAttackCommandFeedback from sourcehold#279, with the style pass. Measured at 98.0 / normalized 94.4 on origin/main 592a17d (full build, both resolver sets on, reccmp). Remaining: the tribe ID is loaded from its parameter slot into ebx before the selectionContainsCombatUnit call instead of after it; nothing writes that slot in between. No functional difference. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::commandUnitsToLocation from sourcehold#279, with the style pass. Measured at 90.3 / normalized 87.2 on origin/main 592a17d (full build, both resolver sets on, reccmp). Remaining: this and index swap edi and ebp (a reg_scores tie), and the original stores the 1 flag and spills the tribe offset before the empty-tribe test, ours around it; that exit returns FALSE without reading either. No functional difference. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::playUnitSelectionSound from sourcehold#279, with the style pass. Measured at 92.4 / normalized 88.5 on origin/main 592a17d (full build, both resolver sets on, reccmp). Remaining: the selected count is loaded into eax and copied to edi (an un-coalesced move) where the original loads it straight into edi; the other lines are jump offsets, the jump table and the alignment filler shifted by those 2 bytes, and tail-jump targets. No functional difference. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TribesState::playUnitCombatSpeechForTarget from sourcehold#279, with the style pass. Measured at 94.4 / normalized 90.7 on origin/main 592a17d (full build, both resolver sets on, reccmp). Remaining: the unitID parameter is loaded once above the range chain and copied, where the original loads it twice at the merge; the two unit-position loads (and the imul that indexes one) swap order; the selected count is copied through eax to edi; the rest are jump offsets and one jump-table entry shifted by those bytes. No functional difference. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Tribe::tribeState is a plain short holding 0, 2 or 3: 0 marks a free slot (createTribe, createTribeForPlayer and getAvailableTribeID search for it), 2 an active tribe (set when a tribe is created, required by getUnitIDForIndexInTribe), and 3 a tribe whose last unit was removed (removeUnitFromTribe, removeUnitFromThisTribeIfInTribe). The TribesState functions in this PR compare and assign these values by name. Tribe.hpp keeps its short field; it can become TribeStateShort upstream. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The 16-bit alias of TribeState, following the Enums/<Name>Short.hpp convention, for Tribe::tribeState (0x18, a short) once the generated header takes it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
- Tribe states by name (Enums::TS_FREE / TS_ACTIVE / TS_EMPTY) instead of 0/2/3. - Map constants: MC_MAP_XY_LIMIT_INCLUSIVE / MC_MAP_XY_LIMIT for the 399 and 400 tile bounds, MC_MAP_SECTOR_SIZE for the wildlife grid's x / 10, y / 10. - createAnimal: the terrain mask 0x4a5014b1 spelled out as its eleven Logic1 flags, L_SEA for the seagull test, UT_NONE for the initial unit type. - moveUnitToBehaviorTarget: SomeTribeBehaviorType names (STBT_0x3f2 ...) for the behaviour cases, BOOLEnum for the found flag. - Decimal instead of hex for speech action IDs, the fade countdown, the map version and the old record sizes. - `dying` tested for truthiness. - Comments that explained forms kept for the match are removed; their content goes into a PR comment. The old-layout note in upgradeTribeArrayLayoutForMapVersion stays, and trimTribeToSize gets a fixme: for the original ignoring its tribeID parameter. Re-measured with a full build and reccmp, both resolver sets on, on main 592a17d: every 100% function stays at 100%. createAnimal goes from 96.1 to 96.5 raw (one fewer reload-order hunk; the rest is unchanged), and the other four register-allocation functions are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
|
These forms are kept because the match needs them. The explanations used to be code comments and are collected here instead. Tribe access through a shifted
Separate loads and guards
Locals and their order
Control flow kept for tail calls
Literal and cast forms
Casts kept for the match (the
Header types I left alone (BRIEF rule 1: main's headers lead unless the match needs a change)
No enum yet
|
Map/Trees/TreeState.hpp already uses TS_ (TS_UNUSED, TS_SPAWNED, TS_ALIVE, TS_TO_BE_REMOVED, TS_STATIC). The tribe states become TRS_FREE, TRS_ACTIVE and TRS_EMPTY, in the enum and in every use. A rename only; quick_diff output for createTribe and removeUnitFromTribe is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
TreeState.hpp/TreeStateShort.hpp become TreeStateEnum.hpp/TreeStateEnumShort.hpp, the types TreeStateEnum/TreeStateEnumShort, and the values TSE_UNUSED, TSE_SPAWNED, TSE_ALIVE, TSE_TO_BE_REMOVED and TSE_STATIC. Tree.hpp's state field and updateTreeStage follow. This frees the TS_ prefix for the TribeState enum in sourcehold#555 (TS_FREE, TS_ACTIVE, TS_EMPTY). A rename only: updateTreeStage compiles and its quick_diff output is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Main's TreeState enum is renamed to TreeStateEnum with TSE_ values in sourcehold#549, which frees TS_ again, so the tribe states return to TS_FREE, TS_ACTIVE and TS_EMPTY. A rename only; quick_diff output for createTribe and removeUnitFromTribe is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
This aligns the enum with sourcehold#555, which carries the same two files byte for byte, so the two PRs do not conflict. TS_ becomes free once sourcehold#549 renames TreeState to TreeStateEnum (TSE_). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
This aligns the enum with sourcehold#554, which carries the same two files byte for byte, so the two PRs do not conflict: - Map/Enums is main's folder for these headers; Map/Units/Enums does not exist on main. - TS_FREE becomes TS_UNUSED and TS_EMPTY becomes TS_DISBANDED. - TS_ is free once sourcehold#549 renames TreeState to TreeStateEnum (TSE_). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Main's upstream Ghidra sync (0701799) carries moveTribeToIndexedNearbyTile's void return; TribesState.hpp and TribesState.func.hpp are taken from main. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
These files are byte-identical to the ones in sourcehold#554 and sourcehold#555: TS_UNUSED = 0, TS_ACTIVE = 2, TS_DISBANDED = 3. The TS_ prefix relies on sourcehold#549 renaming TreeState's values to TSE_. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Main's c1b50c4 renames the TreeStateEnum values to TSE_, and 87e40b6 adds Map/Enums/TribeState.hpp and TribeStateShort.hpp, byte-identical to this branch's copies. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The switch sets isSiege for the siege engines and the engineer and breaks; the siege block and the engineer block follow it as if/fall-through. Same code as the goto form. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
The empty-tribe check and the none-commanded check both break out to the shared return FALSE. Same score as the goto form. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
…e(0) The empty tribe sets noneCommanded in its own branch, and the loop runs in the else branch; one test of the flag then returns FALSE. Same score as the do/while(0) and goto forms. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
Every removed cast was checked one at a time: the file's /FA listing is identical without it and no new warning appears. createAnimal keeps the createTribe result in an int instead of casting a dword local. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp
This PR takes the finished part of draft #279 (
reimpl/TribesState). It has 23TribesStatefunctions:<pct>% | Register allocation differs.Measured on
origin/main55fa231 (merged into this branch), after the goto-free rewrite ofplayUnitSelectionSoundandcommandUnitsToLocation:TribesStatesources.enable_local_functions.pyandenable_reimplemented_data.py.build_parallel.py, then reccmp.TribesState::addUnitToTribeTribesState::createTribeTribesState::createTribeForPlayerTribesState::getAvailableTribeIDTribesState::getUnitIDForIndexInTribeTribesState::moveUnitToBehaviorTargetTribesState::processDeerMovingTribesState::removeUnitFromThisTribeIfInTribeTribesState::removeUnitFromTribeTribesState::snapshotSelectionTribeAndComputeStanceTribesState::spawnDeerLionOrRabbitTribesState::trimTribeToSizeTribesState::updateCamelTribeBehaviorTribesState::updateLionWolfTribeBehaviorTribesState::updateRabbitTribeBehaviorTribesState::upgradeTribeArrayLayoutForMapVersionTribesState::playUnitMoveSpeechTribesState::moveTribeToIndexedNearbyTileTribesState::playAttackCommandFeedbackTribesState::createAnimalTribesState::playUnitCombatSpeechForTargetTribesState::playUnitSelectionSoundTribesState::commandUnitsToLocationWhat is left in the 5 register-allocation functions. I checked the full reccmp diff of each with registers normalized. Every remaining line is a register or slot choice, a load/reload order, a reg-reg copy, or an offset that shifts because of those. No store, computation or branch differs.
playAttackCommandFeedback: the tribe ID is loaded from its parameter slot into ebx before theselectionContainsCombatUnitcall, not after it. Nothing writes that slot in between.createAnimal: for the three spawn-point calls, x and y are reloaded from their parameter slots into other registers, and the reloads and pushes are ordered differently around the store to the tribe's herd size. The same values are pushed in the same order.playUnitCombatSpeechForTarget:imulthat indexes one of them.playUnitSelectionSound: the selected count is loaded into eax and copied to edi, an un-coalesced move, where the original loads it straight into edi. The remaining lines are jump offsets, the jump table and the alignment filler shifted by those 2 bytes, plus tail-jump targets.commandUnitsToLocation:thisand the index swap edi and ebp. reg_scores gives both the same score.Why the last two count as 100%:
playUnitMoveSpeech: the only difference is the target of the two tail jumps toSFXState::playSpeechSFX(0x0044A3A0). In our build they go through main's trampoline.moveTribeToIndexedNearbyTile: the only differing line is the loop-end compare.&field_0xcc4[40].y, 4 bytes pastUnitSelectionDefinedData.Enum headers (from main's 87e40b6, byte-identical to this PR's earlier enum commits):
src/OpenSHC/Map/Enums/TribeState.hppdefinesTS_UNUSED = 0,TS_ACTIVE = 2andTS_DISBANDED = 3, the values ofTribe::tribeState. Reimplement 78 TroopValueState functions at 100% from #275, plus 6 with register allocation differences #554 uses the same headers.TribeStateShort.hppis its 16-bit alias.Tribe.hppis unchanged and keeps itsshortfield.Header changes: none; all headers are main's. Main's Ghidra sync (0701799) now declares
moveTribeToIndexedNearbyTileasvoid, soTribesState.hppandTribesState.func.hppare main's again. The earlier commit that changed them is superseded by the merge.Not taken from the draft:
_memmovestub tosrc/OpenSHC/OS/OS.cpp. It is not needed here:OS.cppis not in any build list, andupgradeTribeArrayLayoutForMapVersionlinks through main'sOS_Func::_memmoveresolver without it.cmake/compiler-flags-gl.txtorcmake/function-visibility.txt, and the draft has none either.Style pass: every file follows
REIMPLEMENTATION_STYLE_GUIDE.mdas it is on main. Each change was measured with the full build above, and no function moved.../TribesState.func.hppis the first include, and the unusedMap.func.hppinclude is gone.usingdeclarations are dropped.x = x + 1and similar.countof(...)replaces the literals 1250, 1249 and 200.if (flag)replaces!= FALSE.0replaces'\0'for a byte value.0x2f(UT_CAMELSHBEAR) and0xd0(US_UNKNOWN_208), andeSFXnames replace the sound IDs in the two selection-sound functions. The remaining hex literals there are now decimal.behaviorType,tribeID,unitType,candidateX,animalCount,spawnIndex, ...).getUnitIDForIndexInTribeusescontinue.moveTribeToIndexedNearbyTile,trimTribeToSizeandcreateAnimalare nowforloops.countofloop to zerosnapshotSelectionTribeAndComputeStance's three stance counters took it from 100% to 90.9% normalized. The three stores stay.forloop incommandUnitsToLocationloads the tribe size separately (movzx+testinstead of a compare against memory). That is an instruction-selection difference, so the do-while stays.Review pass (the
review:commit), measured again with a full build:MC_MAP_XY_LIMIT*,MC_MAP_SECTOR_SIZE), theLogic1flags that make up createAnimal's terrain mask,UT_NONE, and theSTBT_0x3f2… behaviour names replace the numbers.dyingis tested for truthiness.Overlap with open PRs:
addUnitToTribe.cppis also in Reimplement 78 TroopValueState functions at 100% from #275, plus 6 with register allocation differences #554 and TroopValueState leftovers: 4 functions, 2 at 100% #528, which take it from the Reimpl/troop value state development #275 line.There is one commit per function. Each one sets that function's line in
status/addresses-SHC-3BB0A8C1.txt.Draft #279 stays open for the 15 functions that are not done yet:
giveTribeMoveInstruction,giveTribeAnInstruction,spawnQueuedReinforcementWaves,computeTribePercentages,sortTribePathDestinationsByCostgetSpecificUnitFromTribe,isTribePathToDestinationClear,assignAttackTargetsForTribe,applyUnitTopSpeedDelayBasedOnTribeSize,updateTribeUnitAssignmentsdrawFlagsAndUnitDestinations,updateTribeCombatStanceBehavior,predictUnitInterceptPosition,updateTribes,isTribeUnitBlockedByOtherUnitEach of those still has a difference that is more than register allocation:
updateTribes: a duplicated call block.isTribeUnitBlockedByOtherUnit: a recomputedunitID * 0x490.predictUnitInterceptPosition:leavsaddand a reordered computation.applyUnitTopSpeedDelayBasedOnTribeSize: a different frame, a different load form and a block-layoutjmp.updateTribeUnitAssignments,updateTribeCombatStanceBehavior,getSpecificUnitFromTribe: compare selection, store and block differences.🤖 Generated with Claude Code
https://claude.ai/code/session_01XmXCmXCVBvESeaU1djQFjp